<?
$inds = getIndicators($_GET['id']);
$habit= getHabitById($_GET['id']);
$levels=getLevelList();
echo "
<a href=\"" . $_SERVER['PHP_SELF'] . "\">Back To Habit List</a>
<h1>" . stripslashes($habit['habit_name']) . "</h1>
<table border=\"1\">
<tr><th>Indicator</th>
";
foreach($levels as $val) {
	echo "
<th>" . stripslashes($val['level_name']) . 
"</th>";
}
echo "<td>Delete</td></tr>";
foreach($inds as $indicate) {
	echo "<tr><th><a href=\"" . $_SERVER['PHP_SELF'] . "?action=edit&type=indicator&id=" .
$indicate['habit_indicator_id'] . "\">" . stripslashes($indicate['habit_indicator_name']) . 
"</th>";
	for($i=1;$i<=count($levels);$i++) {
		echo "<td>";
		$desc=getDescByIndLev($indicate['habit_indicator_id'],$levels[$i]['level_id']);
		if(!$desc) {
			echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?action=new&type=description&ind=" . 
			$indicate['habit_indicator_id'] . "&lev=" . $levels[$i]['level_id'] . "\">" . 
			"No Description</a>
			";
		} else {
			echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?action=edit&type=description&id=" .
			$desc['habit_description_id'] . "\">" . stripslashes($desc['habit_description_description']) . 
			"(Edit)</a>
			";
		}
		echo "&nbsp;</td>";
	}
	echo "<td><a href=\"" . $_SERVER['PHP_SELF'] . "?action=delete&type=indicator&id=" . 
			$indicate['habit_indicator_id'] . "&habitid=" . $_GET['id'] . "\">" . 
			"DELETE INDICATOR</a></td></tr>";
}
echo "<tr><th colspan=\"" . (count($levels)+2) . "\">" . 
"<a href=\"" . $_SERVER['PHP_SELF'] . "?action=new&type=indicator&habit=" . 
$_GET['id'] . "\">" . 
"New Indicator!</a></th></tr></table>
<a href=\"" . $_SERVER['PHP_SELF'] . "\">Back To Habit List</a>
";